import { ref } from 'vue'
import { defineStore } from 'pinia';

export const useUserStore = defineStore('user', () => {
    const adminname = ref(''); //  用户信息
    const setAdminNameFn = (name: string) => {
        adminname.value = name
    }
    const checkedkeys = ref<string[]>([])  // 用户可访问的菜单项(菜单权限数组)
    const setCheckedKeysFn = (arr: Array<string>) => {
        checkedkeys.value = arr
    }
    const role = ref(0)  // 用户的角色  1:表示管理员  2:超级管理员
    const setRoleFn = (num: number) => {
        role.value = num
    }
    return {
        adminname,
        setAdminNameFn,
        checkedkeys,
        setCheckedKeysFn,
        role,
        setRoleFn
    }
})
